/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class CheckTelIsExist extends AbstractAction
/*    */ {
/*    */   public CheckTelIsExist(AbstractHttpServlet servlet)
/*    */   {
/* 24 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 38 */     User user = super.getLoginUser(request);
/*    */ 
/* 40 */     response.setContentType("text/html;charset=utf-8");
/* 41 */     PrintWriter out = response.getWriter();
/* 42 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 44 */     String tels = Util.getURLParameter(request.getParameter("tel"));
/* 45 */     if ((tels == null) || (tels.trim().length() == 0)) {
/* 46 */       super.showSuccessMessage(response);
/* 47 */       return;
/*    */     }
/*    */ 
/* 50 */     CustomerManager manager = new CustomerManager();
/*    */ 
/* 52 */     StringBuffer result = new StringBuffer();
/* 53 */     for (String tel : tels.split(",")) {
/* 54 */       List items = manager.checkExistTel(
/* 55 */         user.companyId, tel);
/* 56 */       if ((items != null) && (items.size() != 0))
/*    */       {
/* 59 */          for (Object itemO : items) {
                Map item = (Map) itemO;
/* 60 */
                result.append("[" + item.get("Name") + "]" + " \r 电话: " + tel +
/* 61 */             "\r");
            }
/*    */       }
/*    */     }
/* 64 */     if ((result == null) || (result.length() == 0)) {
/* 65 */       jsonObject.put("error", "0");
/*    */     } else {
/* 67 */       jsonObject.put("error", "1");
/* 68 */       jsonObject.put("result", result.toString());
/*    */     }
/* 70 */     out.println(jsonObject);
/* 71 */     out.flush();
/* 72 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.CheckTelIsExist
 * JD-Core Version:    0.6.1
 */